clear all
set more off
set matsize 2000

*input folder path    
global filepath "D:\Dropbox\NREGA Aggregate\shared NREGA lights\replication files"

	  
cd "$filepath"
use "district deposit panel.dta", clear

local pre "yrqtr#c.wage yrqtr#c.outputwage yrqtr#c.state_frac"


*************************************************
*** Table 1, Panel B. Base Analysis: Deposits ***
*************************************************

*col. 1
reghdfe std_dep nregs, absorb(sno yrqtr#st) cluster(sno)

*col. 2
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 , absorb(sno yrqtr#st) cluster(sno)

*col. 3
reghdfe std_dep nregs if  wage!=., absorb(sno yrqtr#st) cluster(sno)

*col. 4
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if wage!=., absorb(sno yrqtr#st) cluster(sno)

*col. 5
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 `pre' , absorb(sno yrqtr#st) cluster(sno)


************************************************
*** Table 2, Panel B.  Heterogeneity by wave ***
************************************************
gen nregs_nr08 = nregs*nr08
label var nregs_nr08 "NREGS $\times$ wave 3"

*col. 1
reghdfe std_dep nregs nregs_nr08 , absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 , absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_dep nregs nregs_nr08 if  wage!=., absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if  wage!=., absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 `pre', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]






/*** APPENDIX ***


******************
*** Summ Stats ***
******************


gen dep100 = dep/100
*Full Summ Stats
sum dep100
sum dep100 if yrqtr<200600
sum dep100 if yrqtr>200600
sum nr06 nr07 nr08 if yrqtr==200401

*Restricted Summ stats
sum dep100 if wage!=.
sum dep100 if yrqtr<200600 & wage!=.
sum dep100 if yrqtr>200600 & wage!=.

sum nr06 nr07 nr08 if yrqtr==200401 & wage!=.


*****************************************************************
*** App Table 2, Panel B.  Association with levels, not trend ***
*****************************************************************
egen std_premean_dep = std(mean_predep)
egen std_pregrowth_dep = std(ddep04_05)

*pre-period mean
*col. 1
reghdfe std_premean_dep nr08 if yrqtr==200401, absorb(st) cluster(st)

*col. 2
reghdfe std_premean_dep nr08 if yrqtr==200401 & wage!=., absorb(st) cluster(st)


*average growth rate in the pre-period
*col. 3
reghdfe std_pregrowth_dep nr08 if yrqtr==200401, absorb(st) cluster(st)

*col. 4
reghdfe std_pregrowth_dep nr08 if yrqtr==200401 & wage!=., absorb(st) cluster(st)


**************************************************************
*** App Table 4, Panel B. Heterogeneity by pre-period wage ***
**************************************************************
gen nregs_wage = nregs*wage
label var nregs_wage "NREGS $\times$ agr. wage (Rs, 1996/7)"

sum wage if yrqtr==200501,d
local p10 = `r(p10)'
local p90 = `r(p90)'

*col. 1
reghdfe std_dep nregs nregs_wage , absorb(sno yrqtr#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 2
reghdfe std_dep nregs nregs_wage i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05, absorb(sno yrqtr#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'

*col. 3
reghdfe std_dep nregs nregs_wage i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 `pre' , absorb(sno yrqtr#st) cluster(sno)
lincom _b[nregs]+_b[nregs_wage]*`p10'
lincom _b[nregs]+_b[nregs_wage]*`p90'


******************************************
*** App Table 5, Panel B. Short Sample ***
******************************************
local sam "yrqtr>=200401 & yrqtr<=201004"

*col. 1
reghdfe std_dep nregs if `sam', absorb(sno yrqtr#st) cluster(sno)

*col. 2
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if `sam', absorb(sno yrqtr#st) cluster(sno)

*col. 3
reghdfe std_dep nregs if  wage!=. & `sam', absorb(sno yrqtr#st) cluster(sno)

*col. 4
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if wage!=. & `sam', absorb(sno yrqtr#st) cluster(sno)

*col. 5
reghdfe std_dep nregs i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 `pre' if `sam', absorb(sno yrqtr#st) cluster(sno)





******************************************************************
*** App Table 6, Panel B.  Short sample: Heterogeneity by wave ***
******************************************************************

*col. 1
reghdfe std_dep nregs nregs_nr08 if `sam', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if `sam', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_dep nregs nregs_nr08 if  wage!=. & `sam', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 if  wage!=. & `sam', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_dep nregs nregs_nr08 i.yrqtr#i.rggvy i.yrqtr#c.ddep04_05 `pre' if  `sam', absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]





********************************************************************
*** App Table 7, Panel B. Base Analysis Deposits: Omitting RGGVY ***
********************************************************************

*col. 1
reghdfe std_dep nregs if yrqtr>=2000 & rggvy==0, absorb(sno yrqtr#st) cluster(sno)

*col. 2
reghdfe std_dep nregs  i.yrqtr#c.ddep04_05 if yrqtr>=2000 & rggvy==0, absorb(sno yrqtr#st) cluster(sno)

*col. 3
reghdfe std_dep nregs if wage!=. & rggvy==0, absorb(sno yrqtr#st) cluster(sno)

*col. 4
reghdfe std_dep nregs  i.yrqtr#c.ddep04_05 if wage!=. & rggvy==0, absorb(sno yrqtr#st) cluster(sno)

*col. 5
reghdfe std_dep nregs  i.yrqtr#c.ddep04_05 `pre' if rggvy==0, absorb(sno yrqtr#st) cluster(sno)




*********************************************************
*** App Table 8, Panel B. Interaction: Omitting RGGVY ***
*********************************************************

*col. 1
reghdfe std_dep nregs nregs_nr08 if rggvy==0 , absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 2
reghdfe std_dep nregs nregs_nr08  i.yrqtr#c.ddep04_05 if rggvy==0, absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 3
reghdfe std_dep nregs nregs_nr08 if wage!=. & rggvy==0, absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 4
reghdfe std_dep nregs nregs_nr08  i.yrqtr#c.ddep04_05 if wage!=. & rggvy==0, absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]

*col. 5
reghdfe std_dep nregs nregs_nr08  i.yrqtr#c.ddep04_05 `pre' if rggvy==0, absorb(sno yrqtr#st) cluster(sno)
lincom  _b[nregs]+_b[nregs_nr08]








